<?php
    $vmodes = array(
        0 => 'Укажите тип',
        1 => 'Обычное',
        2 => 'Специальное'
    );

    $viewables = array(
        0 => 'Скрыть в Re-ports',
        1 => 'Отображать в Re-ports'
    );

    $isneww = array(
        0 => 'Не помечать',
        1 => 'Пометить как новое'
    );

    $action = Arr::getValue($params, 'id', 0)? ACTIONS::VIEW_UPDATE : ACTIONS::VIEW_NEW;

    $vgroups = Arr::getValue($params, 'vgroups', array());
    $vgroups[0] = array('id'=>0, 'title'=>'Не группировать');

    $cities = Arr::getValue($params, 'cities', array());
    $cities[0] = array('id'=>0, 'city_name'=>'Выберите город');

    $btypes = Arr::getValue($params, 'btypes', array());
    $btypes[0] = array('id'=>0, 'name'=>'Выберите тип');

    $views = Arr::getValue($params, 'views', array());
    $views[0] = array('id'=>0, 'obj_name'=>'Нет', 'obj_type'=>0);

    $types = Arr::getValue($params, 'types', array());

    $params['datatypes'][0] = array('id'=>0,'name'=>'Выберите тип данных');
    //$types[0] = array('id'=>0, 'name'=>'Выберите тип');
?>

<form id="vwListForm" name="vwListForm" method="POST" action="#" class="well well-large span7">
    <fieldset>
        <legend>Отображения</legend>
    </fieldset>

    <div class="control-group" style="text-align: right;">
        <button type="button" class="btn btn-success" id="vwDialog-open"><i class="icon-plus icon-white"></i> Добавить </button>
    </div>

    <div id="vwContainer">Получение списка отображений...</div>


</form>





<!--script src="js/floorctrl.js" type="text/JavaScript"></script-->
<?php 
    echo includeFile(APP_PAGE_PARTS.'view_dialog_scripts.php'); 
    echo includeFile(APP_PAGE_PARTS.'forms/form_add_vwgroup.php');
    echo includeFile(APP_PAGE_PARTS.'forms/form_add_city.php');
    echo includeFile(APP_PAGE_PARTS.'forms/form_add_conception.php');
    echo includeFile(APP_PAGE_PARTS.'forms/form_add_view_floor.php');
    echo includeFile(APP_PAGE_PARTS.'forms/form_add_objtype.php', $params);
    echo includeFile(APP_PAGE_PARTS.'forms/form_add_floor_ds.php');
    echo includeFile(APP_PAGE_PARTS.'forms/form_add_sensors.php');
?>
<script>

    function reloadVwList(cont) {
        cont.load('views.php?getList');
    }


$(function() {
    Elm.vwListCont = $('#vwContainer');
    reloadVwList(Elm.vwListCont);

    $('#vwDialog-open').click(function() {
        openVwDialog(0, function(cdata) {
            reloadVwList(Elm.vwListCont);
            if (cdata.hasOwnProperty('insertedId')) {
                Elm.addVwForm[0]['vw_id'].value = cdata.insertedId;
                window.VwFloor.vwId = cdata.insertedId;
            }
        });
    });


});
</script>